<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 1.9.95  (Linux)">
	<META NAME="AUTHOR" CONTENT="Peter Levart">
	<META NAME="CREATED" CONTENT="20050418;8181500">
	<META NAME="CHANGEDBY" CONTENT="Peter Levart">
	<META NAME="CHANGED" CONTENT="20050518;16050100">
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<H1>FUSE-J</H1>
<P STYLE="margin-top: 0.17in; page-break-after: avoid"><FONT FACE="Albany, sans-serif"><FONT SIZE=4>General
Information</FONT></FONT></P>
<P>FUSE-J Java bindings for FUSE (Filesystem in USErspace) is a Java
API that uses JNI bindings to FUSE library and enables writing Linux
filesystems in Java language.</P>
<P>FUSE (Filesystem in USErspace) is a simple interface for userspace
programs to export a virtual filesystem to the linux kernel.</P>
<P>FUSE is writen by Miklos Szeredi (mszeredi@inf.bme.hu) and can be
downloaded from</P>
<P STYLE="margin-left: 0.79in"><CODE><A HREF="http://fuse.sourceforge.net/" TARGET="fuse">http://fuse.sourceforge.net/</A></CODE></P>
<P STYLE="margin-top: 0.17in; page-break-after: avoid"><FONT FACE="Albany, sans-serif"><FONT SIZE=4>News</FONT></FONT></P>
<P><B>2005-05-18: </B>new relase: FUSE-J 2.2.3</P>
<P>JNI part of FUSE-J (<CODE>libjavafs.so</CODE>) now compiles on
amd64 Linux machines (if it runs remains to be seen). The changes
that were done are:</P>
<UL>
	<LI><P>added option <CODE>-fPIC</CODE> to gcc invocations in
	<CODE>jni/Makefile</CODE>.</P>
</UL>
<UL>
	<LI><P><CODE>LDPATH</CODE> variable in <CODE>jni/Makefile</CODE> was
	hardcoded. Now it is set by including <CODE>jvm_ldpath.def</CODE>
	file that is generated by running a Java program which produces
	correct library paths by looking into
	<CODE>System.getProperty(“java.library.path”)</CODE>. This way
	we can potentially build with any JDK version on any FUSE supported
	platform (not just SUN's JDK on i386 Linux).</P>
	<LI><P><CODE>libjavafs.so</CODE> is now linked with a shared
	<CODE>libfuse.so</CODE> (it was linked with static <CODE>libfuse.a</CODE>
	before, but that didn't work on amd64 machines). When mounting a
	filesystem you have to set <CODE>LD_LIBRARY_PATH</CODE> to include
	both <CODE>libfuse.so</CODE> directory and <CODE>libjavafs.so</CODE>
	directory (see the example <CODE>zipfs_mount.sh</CODE> script).</P>
	<LI><P>Note that FUSE-J 2.2.3 compiles on amd64 machines
	(compilation tested on Fedora Core 3 for amd64) but was not
	run-tested on this architecture. That's because I don't have root
	access to the SourceForge's compile-farm amd64-linux machine which
	is needed to be able to load FUSE kernel module. Can someone try
	this version (example zipfs_mount.sh is enough) on amd64 (and maybe
	other) architecture?</P>
</UL>
<UL>
	<LI><P STYLE="font-weight: medium">Download this version from:</P>
</UL>
<P STYLE="margin-left: 0.79in"><CODE><A HREF="http://www.select-tech.si/fuse/fuse-j-2.2.3.tar.gz">http://www.select-tech.si/fuse/fuse-j-2.2.3.tar.gz</A></CODE></P>
<P><B>2005-04-20: </B>new relase: FUSE-J 2.2.2</P>
<P>Changes:</P>
<UL>
	<LI><P STYLE="font-weight: medium">The main change in this release
	is that the native to Java API is now byte oriented (not character
	oriented as before) and that encoding of file names and paths is
	done in Java (not forced to UTF-8 anymore). This is acomplished with
	the following:</P>
</UL>
<UL>
	<P>The interface that JNI bindings invoke is now <CODE>fuse.FuseFS
	</CODE>(and not <CODE>fuse.Filesystem</CODE> any more). This
	interface is byte oriented. This means that any file or path name is
	passed as either a direct <CODE>java.nio.ByteBuffer</CODE> (the
	fastest way for Java to read from and/or write to native memeory
	locations) or a <CODE>byte[] </CODE>array. It is not meant that Java
	filesystem implementations would implement this interface directly
	but instead use <CODE>fuse.FilesystemToFuseFSAdapter </CODE>class to
	convert between a byte oriented and String oriented API. You can
	specify an encoding as a parameter to f<CODE>use.FilesystemToFuseFSAdapter</CODE>
	constructor.</P>
	<LI><P>Multithreaded operation is fixed now. If FUSE library calls
	Java in multiple threads, those threads are now bound to Java
	threads as daemon threads so that after unmounting the filesystem
	(when main_loop returns) JVM can exit normally.</P>
</UL>
<UL>
	<LI><P STYLE="font-weight: medium">Download this version from:</P>
</UL>
<P STYLE="margin-left: 0.79in"><CODE><A HREF="http://www.select-tech.si/fuse/fuse-j-2.2.2.tar.gz">http://www.select-tech.si/fuse/fuse-j-2.2.2.tar.gz</A></CODE></P>
<P><B>2005-04-18 afternoon:</B> new release: FUSE-J 2.2.1</P>
<P STYLE="font-weight: medium">Changes:</P>
<UL>
	<LI><P>Incorporated a patch from Daniel Wunsch &lt;<A HREF="mailto:the.gray@gmx.net">the.gray@gmx.net</A>&gt;
	(thanks) for a bug that prevented the propagation of <CODE>errno</CODE>
	from Java to C.</P>
	<LI><P>Started to refactor for using new FUSE API (<CODE>FUSE_USE_VERSION
	22</CODE>). This caused the Java API to change. <CODE>fuse.Filesystem
	</CODE>interface has 2 new methods (<CODE>flush, fsync</CODE>) and
	some methods have changed signature (namely: <CODE>open</CODE> now
	returns a filehandle, <CODE>read</CODE>, <CODE>write</CODE> and
	<CODE>release</CODE> have an additional filehandle parameter and
	<CODE>write</CODE> has an aditional flag indicating a <CODE>writepage</CODE>
	operation).</P>
	<LI><P><CODE>fuse.FuseDirEnt</CODE> has an aditional <CODE>inode</CODE>
	field, so that a filesystem can return inode numbers.</P>
	<LI><P>Old <CODE>fuse.Filesystem</CODE> interface has been renamed
	to <CODE>fuse.Filesystem1</CODE> and an adapter class
	<CODE>fuse.Filesystem1ToFilesystemAdapter</CODE> has been writen so
	that old filesystem implementations can be used unchanged (just
	replace <CODE>implements fuse.Filesystem </CODE>with <CODE>implements
	fuse.Filesystem1</CODE>).</P>
	<LI><P STYLE="font-weight: medium">Download this version from:</P>
</UL>
<P STYLE="margin-left: 0.79in"><CODE><A HREF="http://www.select-tech.si/fuse/fuse-j-2.2.1.tar.gz">http://www.select-tech.si/fuse/fuse-j-2.2.1.tar.gz</A></CODE></P>
<P STYLE="font-weight: medium">Plans for future include:</P>
<UL>
	<LI><P>Change <CODE>fuse.Filesystem</CODE> API to use <CODE>byte[]</CODE>
	instead of <CODE>String</CODE> so that file names encoding will not
	be forced to UTF-8 as is now done in JNI bindings but could be done
	in Java instead. Update <CODE>fuse.Filesystem1ToFilesystemAdapter</CODE>
	to work with this new API. <B>(DONE in FUSE-J 2.2.2)</B></P>
	<LI><P>Extend <CODE>fuse.Filesystem</CODE> API to include methods
	for working with extended attributes.</P>
	<LI><P>Figure out how to pass the client info (<CODE>struct
	fuse_context</CODE>) to the Java API.</P>
</UL>
<P><B>2005-04-18:</B> After a year and a half of silence and a few
Emails I got from various people asking about the FUSE-J binding I
decided to update the software to current FUSE version (2.2.1).</P>
<P>I used the patch from Tim Moreton &lt;<A HREF="mailto:tim.moreton@cl.cam.ac.uk">tim.moreton@cl.cam.ac.uk</A>&gt;
(thanks) and made some other minor modifications to compile and work
with Java 5. You can download this version from:</P>
<P STYLE="margin-left: 0.79in"><CODE><A HREF="http://www.select-tech.si/fuse/fuse-j-2.2.tar.gz">http://www.select-tech.si/fuse/fuse-j-2.2.tar.gz</A></CODE></P>
<P STYLE="margin-top: 0.17in"><FONT FACE="Albany, sans-serif"><FONT SIZE=4>Installation</FONT></FONT></P>
<P>First you must get and install the FUSE kernel module and library
(se above). By default FUSE library is installed into <CODE>/usr/local/lib</CODE>
and header files in <CODE>/usr/local/include</CODE> directories. If
you install FUSE to some other directory, you should edit <CODE>build.conf</CODE>
and set <CODE>FUSE_HOME</CODE> variable to the base directory of your
FUSE library/headers instalation.</P>
<P>You will need JDK 1.4 or above (I'm using JDK 1.5.0_02 from
<A HREF="http://java.sun.com/" TARGET="java">http://java.sun.com</A>).
FUSE-J will not work or compile with JDK 1.3 or earlier since it uses
<CODE>JNI_VERSION_1_4</CODE> features (such as direct
<CODE>java.nio.ByteBuffer</CODE>). Edit <CODE>build.conf</CODE> and
set <CODE>JDK_HOME</CODE> variable to point to the JDK installation.</P>
<P STYLE="margin-left: 0.79in"><CODE>run 'make'</CODE></P>
<P>This will first compile Java sources from <CODE>src</CODE>
directory into class files in <CODE>build</CODE> directory. It will
then run the JNI bindings generation process which will produce two
files: <CODE>jni/javafs_bindings.h</CODE> &amp;
<CODE>jni/javafs_bindings.c</CODE>. After that the <CODE>jni/libjavafs.so</CODE>
shared library for inclusion in the JVM will be built.</P>
<P STYLE="margin-top: 0.17in; page-break-after: avoid"><FONT FACE="Albany, sans-serif"><FONT SIZE=4>How
To Use</FONT></FONT></P>
<P>FUSE-J is made up of two main parts:</P>
<UL>
	<LI><P>A JNI shared library (<CODE>jni/libjavafs.so</CODE>)</P>
	<LI><P>A Java API for implementing and mounting filesystems writen
	in Java (Java classes in <CODE>build</CODE> directory)</P>
</UL>
<P>You can try and test the example ZIP filesystem with the following
command:</P>
<P STYLE="margin-left: 0.79in"><CODE>cd fuse-j-build-dir</CODE></P>
<P STYLE="margin-left: 0.79in"><CODE>./zipfs_mount.sh some.zip
/mnt/point</CODE></P>
<P>And then use fusermount to unmount it:</P>
<P STYLE="margin-left: 0.79in"><CODE>fusremount -u /mnt/point</CODE></P>
<P>Here's how to create your very own virtual filesystem in three
easy steps:</P>
<OL>
	<LI><P>Implement the <CODE>fuse.Filesystem</CODE> interface (see
	example <CODE>fuse.zipfs.ZipFilesystem</CODE>)</P>
	<LI><P>call <CODE>fuse.FuseMount.mount(String[] args,
	fuse.Filesystem filesystem)</CODE></P>
</OL>
<P STYLE="margin-left: 0.79in">...where <CODE>args</CODE> is an array
of arguments passed to FUSE library's <CODE>fuse_main</CODE> function
and must contain:</P>
<P STYLE="margin-left: 1.58in">mountpoint as 1st argument</P>
<P STYLE="margin-left: 1.58in">optional options as 2nd and subsequent
arguments (see FUSE docs for more info)</P>
<P STYLE="margin-left: 0.79in">...and <CODE>filesystem</CODE> is an
instance of a class implementing <CODE>fuse.Filesystem</CODE>
interface</P>
<OL START=3>
	<LI><P><CODE>ls -al /mount/point</CODE></P>
</OL>
<P STYLE="margin-top: 0.17in; page-break-after: avoid"><FONT FACE="Albany, sans-serif"><FONT SIZE=4>Author</FONT></FONT></P>
<P>FUSE-J is writen by Peter Levart (<A HREF="mailto:peter@select-tech.si">peter@select-tech.si</A>)</P>
<P>FUSE is writen by Miklos Szeredi (<A HREF="mailto:mszeredi@inf.bme.hu">mszeredi@inf.bme.hu</A>)</P>
<P><BR><BR>
</P>
</BODY>
</HTML>